package org.jeecg.modules.jxc.goodstype.controller;

import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.jxc.goodstype.entity.JxcGoodsType;
import org.jeecg.modules.jxc.goodstype.service.JxcGoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @description:
 * @company: yaorange
 * @author: Mr.Yu
 * @version: 1.0
 * @create: 2021-12-21 09:32:40
 */

@RestController
@RequestMapping("/goodsType")
public class JxcGoodsTypeController {

    @Autowired
    private JxcGoodsTypeService goodsTypeService;

    /**
     * 查询父节点
     * @return
     */
    @GetMapping("/stateTree")
    public ResponseEntity<List<Map<String,Object>>> stateGoodsType(){
        List<Map<String,Object>> goodsType=goodsTypeService.selectByList();
        return ResponseEntity.ok(goodsType);
    }


    @GetMapping("/tree")
    public ResponseEntity<List<JxcGoodsType>> goodsType(){
        List<JxcGoodsType> list=goodsTypeService.selectTree();

        return ResponseEntity.ok(list);
    }

    @GetMapping("/children/{id}")
    public ResponseEntity<List<JxcGoodsType>> children(@PathVariable String id){
        List<JxcGoodsType> list=goodsTypeService.selectById(id);
        return ResponseEntity.ok(list);
    }

}
